package team.tunan.controller;



import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import team.tunan.common.Result;
import team.tunan.dto.StockPageDto;
import team.tunan.entity.Stock;
import team.tunan.service.IStockService;
import team.tunan.service.ISupplierService;

/**
 * <p>
 * 产品表	 前端控制器
 * </p>
 *
 * @author sqx
 * @since 2023-12-24
 */
@RestController
@RequestMapping("/stock")
public class StockController {
    @Autowired
    private IStockService iStockService;

    @PostMapping("/insertStock")
    public Result insertStock(@RequestBody Stock stock){
        return Result.success(iStockService.insertStock(stock));
    }

    @PostMapping("/updateStock")
    public Result updateStock(@RequestBody Stock stock){
        return Result.success(iStockService.updateStock(stock));
    }

    @GetMapping("/deleteStock/{id}")
    public Result deleteStock(@PathVariable String id){
        return Result.success(iStockService.deleteStock(id));
    }

    @PostMapping("/selectPage")
    public Result<Page<Stock>> selectPage(@RequestBody StockPageDto stockPageDto){
        return Result.success(iStockService.selectPage(stockPageDto));
    }
    @GetMapping("/selectByStockId/{StockId}")
    public Result selectByStockId(@PathVariable Integer StockId){
        return Result.success(iStockService.selectByStockId(StockId));
    }

    @GetMapping("/list")
    public Result list(){
        return Result.success(iStockService.list());
    }
}

